﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericGA.reader.regex;

namespace GenericGA.reader.tree
{
    /// <summary>
    /// A rule describing what children can be attached to a node.
    /// </summary>
    /// <typeparam name="N">The type of the nodes.</typeparam>
    public class Rule<N>
    {

        /// <summary>
        /// The node being described by the rule.
        /// </summary>
        public INodeFactory<N> Node { get; private set; }

        /// <summary>
        /// A regular expression which describes what children the node can have.
        /// </summary>
        public Regex<INodeFactory<N>> ChildrenPattern { get; private set; }

        /// <summary>
        /// Constructor to create a new rule.
        /// </summary>
        /// <param name="node">The node being described.</param>
        /// <param name="childrenPattern">A regular expression describing what children can be attached to the node.</param>
        public Rule(INodeFactory<N> node, Regex<INodeFactory<N>> childrenPattern)
        {
            this.Node = node;
            this.ChildrenPattern = childrenPattern;
        }

    }
}
